"""
Demonstrates how to use the background scheduler to schedule a job that executes on 3 second
intervals.
"""

from datetime import datetime
import time
import os
import pynotify

from apscheduler.schedulers.background import BackgroundScheduler


def tick(msg):
    title_notify = "Test"
    msg_notify = msg
    pynotify.init("test")
    rnotify = pynotify.Notification(title_notify, msg_notify)
    rnotify.show()


if __name__ == '__main__':
    scheduler = BackgroundScheduler()
    scheduler.add_job(tick, 'interval', seconds=3, args=["hello world"])
    scheduler.start()
    
    scheduler1 = BackgroundScheduler()
    scheduler1.add_job(tick, 'interval', seconds=3, args=["Hi, you are sb"])
    scheduler1.start()
    
    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))

    try:
        # This is here to simulate application activity (which keeps the main thread alive).
        while True:
            time.sleep(2)
    except (KeyboardInterrupt, SystemExit):
        # Not strictly necessary if daemonic mode is enabled but should be done if possible
        scheduler.shutdown()
